import Vue from 'vue'
import Router from 'vue-router'
// webpackChunkName 后的内容为打包对应的部分
// loginpart
const login = () => Promise.resolve(import(/* webpackChunkName: "login" */ '../page/login/login'))
const register = () => Promise.resolve(import(/* webpackChunkName: "login" */ '../page/login/register'))
const setPwd = () => Promise.resolve(import(/* webpackChunkName: "login" */ '../page/login/setPwd'))
// personHome
const home = () => Promise.resolve(import(/* webpackChunkName: "home" */ '../page/home/index'))
const productHome = () => Promise.resolve(import(/* webpackChunkName: "home" */ '../page/productDetail/detail'))
const devList = () => Promise.resolve(import(/* webpackChunkName: "home" */ '../page/productDetail/devList'))
const address = () => Promise.resolve(import(/* webpackChunkName: "home" */ '../page/address/index'))
const addressDetail = () => Promise.resolve(import(/* webpackChunkName: "home" */ '../page/address/detail'))
const productAccount = () => Promise.resolve(import(/* webpackChunkName: "home" */ '../page/productAccount/index'))
const phoneControl = () => Promise.resolve(import(/* webpackChunkName: "home" */ '../page/phoneControl/index'))
const orderList = () => Promise.resolve(import(/* webpackChunkName: "home" */ '../page/orderList/index'))
const chart = () => Promise.resolve(import(/* webpackChunkName: "home" */ '../page/flowChart/index'))
const bindDev = () => Promise.resolve(import(/* webpackChunkName: "home" */ '../page/bindDev/index'))

const person = () => Promise.resolve(import(/* webpackChunkName: "main" */ '../page/person/index'))
const error = () => Promise.resolve(import(/* webpackChunkName: "main" */ '../page/error/index'))
const errorDetail = () => Promise.resolve(import(/* webpackChunkName: "main" */ '../page/error/errorDetail'))

const store = () => Promise.resolve(import(/* webpackChunkName: "store" */ '../page/store/index'))
const distribute = () => Promise.resolve(import(/* webpackChunkName: "store" */ '../page/store/distribute'))
const pay = () => Promise.resolve(import(/* webpackChunkName: "store" */ '../page/store/pay'))

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/login',
      name: 'login',
      component: login,
      meta: {
        keepAlive: false
      }
    },
    {
      // type=register为登录 type=setPwd 为找回密码。或者修改密码 最终修改密码成功之后都进入登录页面，不让用户直接进入
      path: '/register/:action',
      name: 'register',
      component: register,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/setPwd/:action',
      name: 'setPwd',
      component: setPwd,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/home',
      name: 'home',
      component: home,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/productHome',
      name: 'productHome',
      component: productHome,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/devList',
      name: 'devList',
      component: devList,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/address',
      name: 'address',
      component: address,
      children: [
        {path: 'default', component: address},
        {path: 'add', component: address}
      ],
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/addressDetail',
      name: 'addressDetail',
      component: addressDetail,
      children: [
        {path: 'addadress', component: addressDetail},
        {path: 'edtadress', component: addressDetail}
      ],
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/productAccount',
      name: 'productAccount',
      component: productAccount,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/phoneControl',
      name: 'phoneControl',
      component: phoneControl,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/orderList',
      name: 'orderList',
      component: orderList,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/flowChart',
      name: 'chart',
      component: chart,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/bindDev',
      name: 'bindDev',
      component: bindDev,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/person',
      name: 'person',
      component: person,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/error',
      name: 'error',
      component: error,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/errorDetail/:type',
      name: 'errorDetail',
      component: errorDetail,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/store',
      name: 'store',
      component: store,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/distribute',
      name: 'distribute',
      component: distribute,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/pay',
      name: 'pay',
      component: pay,
      meta: {
        keepAlive: false
      }
    }
  ]
})
